package com.jdbcUtil;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Scanner;

import org.junit.Test;



public class test {
	
	
@Test
	public void tes() throws SQLException{
		jdbcUtil jd = new jdbcUtil();
		Connection conn = jd.getConnection();
		Scanner sc = new Scanner(System.in);
		System.out.println("请输入用户名：");
		String nn = sc.next();
		System.out.println("请输入密码：");
        String pwd = sc.next();		
		StatementUtil su = new StatementUtil();
		Statement sm = su.getStatement(conn);
		ResultsetUtil ru = new ResultsetUtil();
		String sql = "select message from cgw_t_login where username='"+nn+"'and password='"+pwd+"'"; 
		ResultSet rs = ru.getResult(sm,sql);
	    if(rs.next()){
	    	System.out.println("啦啦啦德瑪西亞");
	    }else {
	    	System.out.println("登录失败");
	    }
	    rs.close();
	    sm.close();
	    conn.close();
		
	}
@Test
public void tes1() throws SQLException{
	jdbcUtil jd = new jdbcUtil();
	Connection conn = jd.getConnection();
	Scanner sc = new Scanner(System.in);
	System.out.println("请输入用户名：");
	String nn = sc.next();
	System.out.println("请输入密码：");
    String pwd = sc.next();		
	PreparedStatementUtil su = new PreparedStatementUtil();
	String sql = "select message from cgw_t_login where username=? and password=? "; 
	PreparedStatement psm = su.getPreparedStatemen(conn, sql);
	psm.setString(1, nn);
	psm.setString(2, pwd);
	ResultsetUtil ru = new ResultsetUtil();
	ResultSet rs = ru.getResult(psm);
    if(rs.next()){
    	System.out.println("s");
    }else {
    	System.out.println("登录失败");
    }
	rs.close();
	psm.close();
	conn.close();
}
}
